<?php
/**
 * 前台用户中心页面
 * author wang
 * mail:970633164@qq.com
 */
define("PHP_IN",true);
require "include/init.php";
require ROOT_PATH."checklogin.php";
require ROOT_PATH."smarty_connection.php";

$page = isset($_GET['page']) ? $_GET['page'] : 1 ;
$pagesize = 3 ;
$pagestart = ($page-1) * $pagesize ;

$sql = "SELECT count(*) AS num FROM guestbook ";
$result =$db->query($sql);
$count = 0 ;
$row = $db->fetch_one($result);
$count = $row['num'] ;

$pagecount = ceil($count/$pagesize);
$page_links = page_links($pagecount,$page,"user_msg.php?$page");   //分页

$sql = "SELECT * FROM guestbook ORDER BY msgid DESC LIMIT $pagestart,$pagesize";   //联系我们
$result = $db->query($sql);
$guestbook = $db->fetch_all($result);

$smarty->assign("guestbook",$guestbook);
$smarty->assign("page_links",$page_links);

$smarty->display("user_msg.tpl");
$db->close();
?>
